package com.webserver.core;

import com.webserver.http.HttpServleRequest;

import java.io.IOException;
import java.io.InputStream;
import java.net.Socket;
import java.util.HashMap;
import java.util.Map;

/**
 * 线程任务
 * 负责与特定的客户端进行HTTP交互
 */
public class ClientHandler implements Runnable {
    private Socket socket;
    //启动一个线程处理该客户端交互(引用)
    public ClientHandler(Socket socket){
        this.socket=socket;
    }
    @Override
    public void run() {
        try {
            //http//localhost:8088
            //1解析请求
            HttpServleRequest request=new HttpServleRequest(socket);

            //2处理请求


            //3发送响应

        } catch (IOException e) {
            e.printStackTrace();
            //挂电话 断开连接
        } finally {
            try {
                //响应后断开连接
                socket.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

    }


    }

